const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    id: {
      type: DataTypes.BIGINT.UNSIGNED,
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "支付日志id",
      field: "id"
    },
    log_no: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付日志订单号",
      field: "log_no"
    },
    user_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "用户id",
      field: "user_id"
    },
    business_type: {
      type: DataTypes.CHAR(180),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "业务类型，字符串（如：订单 order、钱包充值 wallet、会员购买 member、等…）",
      field: "business_type"
    },
    status: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "状态（0待支付, 1已支付, 2已关闭）正常30分钟内未支付将关闭",
      field: "status"
    },
    payment: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付方式标记",
      field: "payment"
    },
    payment_name: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付方式名称",
      field: "payment_name"
    },
    subject: {
      type: DataTypes.CHAR(255),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "订单名称",
      field: "subject"
    },
    total_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "业务订单金额",
      field: "total_price"
    },
    pay_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付金额",
      field: "pay_price"
    },
    trade_no: {
      type: DataTypes.CHAR(100),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付平台交易号",
      field: "trade_no"
    },
    buyer_user: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付平台用户帐号",
      field: "buyer_user"
    },
    pay_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付时间",
      field: "pay_time"
    },
    close_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "关闭时间",
      field: "close_time"
    },
    add_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "添加时间",
      field: "add_time"
    }
  };
  const options = {
    tableName: "sxo_pay_log",
    comment: "",
    indexes: [{
      name: "payment",
      unique: false,
      type: "BTREE",
      fields: ["payment"]
    }, {
      name: "status",
      unique: false,
      type: "BTREE",
      fields: ["status"]
    }, {
      name: "business_type",
      unique: false,
      type: "BTREE",
      fields: ["business_type"]
    }, {
      name: "total_price",
      unique: false,
      type: "BTREE",
      fields: ["total_price"]
    }, {
      name: "pay_price",
      unique: false,
      type: "BTREE",
      fields: ["pay_price"]
    }, {
      name: "add_time",
      unique: false,
      type: "BTREE",
      fields: ["add_time"]
    }, {
      name: "pay_time",
      unique: false,
      type: "BTREE",
      fields: ["pay_time"]
    }, {
      name: "close_time",
      unique: false,
      type: "BTREE",
      fields: ["close_time"]
    }]
  };
  const SxoPayLogModel = sequelize.define("sxo_pay_log_model", attributes, options);
  return SxoPayLogModel;
};